<#-- 导入模版定义文件-->
<#include "../template/template_editPage.ftl">
<@edit title="菜单操作">
<#if !code??>
	<#assign isAdd = true />
<#else>
    <#if level??>
		<#assign isAdd = true />
	<#else>
		<#assign isEdit = true />
	</#if>
</#if>
<body class="input">
<script type="text/javascript">
	$().ready( function() {
	
		var $validateErrorContainer = $("#validateErrorContainer");
		var $validateErrorLabelContainer = $("#validateErrorContainer ul");
		var $validateForm = $("#inputForm");
		var $tab = $("#tab");
	
		// Tab效果
		$tab.tabs(".tabContent", {
			tabs: "input"
		});
		
		// 表单验证
		$validateForm.validate({
			errorContainer: $validateErrorContainer,
			errorLabelContainer: $validateErrorLabelContainer,
			wrapper: "li",
			errorClass: "validateError",
			ignoreTitle: true,
			rules: {
				"permission.name": {
						required: true
				},
				"permission.sort": {
						integer: "true"
				}	
			},
			messages: {
				"permission.name": {
						required: "请填写名称"
				},
				"permission.sort": {
						integer: "排序必须为整数"
				}			
			},
			submitHandler: function(form) {
				$(form).find(":submit").attr("disabled", true);
				form.submit();
			}
		});
		<#if actionErrors??&&(actionErrors?size > 0)>
			$.dialog({type: "warn", content: "<#list errorMessages as list>${list}<br></#list>",
			 modal: true, autoCloseTime: 3000});
		</#if>
	});
	</script>
	<div class="body">
		<div class="inputBar">
			<h1><span class="icon">&nbsp;</span><#if isAdd??>添加<#if level??>${level}<#else>1</#if>级菜单<#else>编辑<#if level??>${level}级</#if>菜单</#if></h1>
		</div>
		<div style="display: none;" id="validateErrorContainer" class="validateErrorContainer">
			<div class="validateErrorTitle">以下信息填写有误,请重新填写</div>
				<ul></ul>
			</div>
		</div>		
		<form id="inputForm" class="validate" action="<#if isAdd??>${web_base}/system/permission!save.htm<#else>${web_base}/system/permission!editPermission.htm</#if>" method="post">
			<table class="inputTable tabContent">

				<tr>
					<th>
						名称：
					</th>
					<td>
						<input type="text" name="permission.name" class="formText {required: true}" value="${(permission.name)!}"/>
						<label class="requireField">*</label>
					</td>
				</tr>
				<#if !level??>
				<tr <#if isEdit??>style="display:none"</#if>>
					<th>
						是否为菜单：
					</th>
					<td>					
						<select name="permission.isMenu" class="formText {required: true}">
								<option value="true" <#if isEdit??><#if permission.isMenu?default(true)==true>selected="selected"</#if></#if>>
									是
								</option>
								<option value="false" <#if isEdit??><#if permission.isMenu?default(true)==false>selected="selected"</#if></#if>>
									否
								</option>
							</select>
						<label class="requireField">*</label>
					</td>
				</tr>
				</#if>
				<tr style="display:none">
					<th>
						级别:
					</th>
					<td>
						<input type="hidden" name="permission.level" class="formText" value="<#if isAdd??><#if level??>${level}<#else>0</#if><#else>${(permission.level)!}</#if>" />
					</td>
				</tr>
				<tr style="display:none">
					<th>
						父权限代码:
					</th>
					<td>
						<input type="text" name="permission.code"  value="${(permission.code)!}" />
						<input type="text" name="permission.parentCode" value="<#if isAdd??><#if code??>${code}</#if><#else>${(permission.parentCode)!}</#if>" />
					</td>
				</tr>
				<tr>
					<th>
						排序:
					</th>
					<td>
						<input type="text" name="permission.sort" class="formText" value="<#if isAdd??>0<#else>${(permission.sort)!}</#if>" />
					</td>
				</tr>
				<tr>
					<th>
						URL:
					</th>
					<td>
						<input type="text" name="permission.url" class="formText" value="${(permission.url)!}" />
					</td>
				</tr>
			</table>
			<div class="buttonArea">
				<input type="submit" class="formButton" value="确  定" hidefocus="true" />&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="button" class="formButton" onclick="window.history.back(); return false;" value="返  回" hidefocus="true" />
			</div>
		</form>
	</div>
</body>
</@edit>